package cn.pegasus.teamwork.pegasus.service.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.pegasus.teamwork.pegasus.entity.BussEquipmentInfo;
import cn.pegasus.teamwork.pegasus.mapper.BussEquipmentInfoMapper;
import cn.pegasus.teamwork.pegasus.service.BussEquipmentInfoService;
import cn.iyizhan.teamwork.base.service.impl.BaseServiceImpl;
import cn.iyizhan.teamwork.base.util.PageObject;

/**
 * @author ryan.bian
 * @version 
 */
@Service("bussEquipmentInfoService")
public class BussEquipmentInfoServiceImpl extends BaseServiceImpl<BussEquipmentInfo, BussEquipmentInfoMapper> implements BussEquipmentInfoService {
	// 注入当前dao对象
    @Autowired
    private BussEquipmentInfoMapper bussEquipmentInfoMapper;

    public BussEquipmentInfoServiceImpl() {
        setMapperClass(BussEquipmentInfoMapper.class, BussEquipmentInfo.class);
    }

	@Override
	public PageObject<BussEquipmentInfo> PageList(Map<String, Object> map) {
		map.put("sortName", "create_time");
        map.put("sortOrder", "desc");
		return super.Pagequery(map);
	}

	@Override
	public List<BussEquipmentInfo> findEquipmentList() {
		BussEquipmentInfo i = new BussEquipmentInfo();
		return bussEquipmentInfoMapper.selectByObject(i);
	}

	@Override
	public void addEq(Long userId, Map<String, Object> map) {
		BussEquipmentInfo info = M2O(map);
		info.setCreateTime(new Date());
		info.setCreateUserId(userId);
		info.setLastUpdateTime(new Date());
		info.setLastUpdateUserId(userId);
		bussEquipmentInfoMapper.insertByEntity(info);
		
	}

	@Override
	public void updateEq(Long userId, Map<String, Object> map) {
		BussEquipmentInfo info = M2O(map);
		info.setLastUpdateTime(new Date());
		info.setLastUpdateUserId(userId);
		bussEquipmentInfoMapper.updateByEntity(info);
	}

	@Override
	public void delete(Long userId, Integer id) {
		BussEquipmentInfo info = new BussEquipmentInfo();
		info.setCurrType(0);
		info.setLastUpdateTime(new Date());
		info.setLastUpdateUserId(userId);
		bussEquipmentInfoMapper.updateByEntity(info);
		
	}

	@Override
	public BussEquipmentInfo findEqInfo(Integer id) {
		BussEquipmentInfo info = new BussEquipmentInfo();
		info.setId(id);
		return bussEquipmentInfoMapper.selectSingle(info);
	}
    
 
}
